package org.example.Voutils;

public class ShareDataOne {
    private Integer number=0;
    public synchronized void increment() {
        try {
            while (number!=0){
             this.wait();
            }
            number++;
            System.out.println(Thread.currentThread().getName()+":"+number);
            this.notifyAll();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
        }
    }

    public synchronized void decrement() {
        try {
            while (number != 1) {
                this.wait();
            }
            number--;
            System.out.println(Thread.currentThread().getName() + ":" + number);
            this.notifyAll();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
        }
    }
}
